package com.dhc.appbusinessfrm.task;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * Created by xy on 2015/6/18.
 */
public class TaskPoolServer {

    private final static int maxTaskCount = 40;

    private final static int corePoolSize = 1;

    private final static int maximumPoolSize = 1;

    private final static long keepAliveTime = 0L;

    private static PriorityBlockingQueue<Runnable> priorityList = new PriorityBlockingQueue(maxTaskCount, new TaskPriorityComparator());

    private static ExecutorService netPool = new TaskThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.MILLISECONDS, priorityList);

    public static Future<AsyncTask> ExecAsyncTask(CallableTask callableTask) {
        Future<AsyncTask> future = netPool.submit(callableTask);
        return future;
    }
}
